package com.kanavi.stand.controller;


import com.common.boot.common.CommonResult;
import com.kanavi.stand.anno.Log;
import com.kanavi.stand.service.UserStandInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * <p>
 * 用户小程序停留时长记录表 前端控制器
 * </p>
 *
 * @author tanghailan
 * @since 2020-10-22
 */
@RestController
@RequestMapping("/stand/userStandInfo")
@Slf4j
public class UserStandInfoController {

    private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger();
    private static Integer INTEGER = 0;
    @Resource
    private UserStandInfoService userStandInfoService;

    /**
     * 上报用户停留时间至 redis
     *
     * @param userId     人员id
     * @param standStart 开始时间戳
     * @param standEnd   结束时间戳
     */
    @PostMapping("putUserStand")
    @Log("保存信息")
    public CommonResult putUserStand(String userId, Long standStart, Long standEnd){
//        System.out.println("请求次数"+INTEGER++);
        System.out.println("请求次数"+ATOMIC_INTEGER.incrementAndGet());
        userStandInfoService.putUserStand(userId,standStart,standEnd);
        return CommonResult.success(null);
    }

}

